﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using GNF;
using GNF.ParserLibrary;
using GNF.GNFService.GNFServer;
using GNF.Common;

namespace GNF.GNFService
{
    public partial class GNFService : ServiceBase
    {

        #region private members
        
        private IParser _Parser = null;

        //private GPSDevice _GPS = null;

        private RandomDataGNFServer myserver = null;

        #region GPS DATA



        #endregion


        #endregion

        public GNFService()
        {
            InitializeComponent();
            this.ServiceName = "GNFService";
        }

        #region service memebers

        protected override void OnStart(string[] args)
        {

            if (myserver == null)
            {
                myserver = new RandomDataGNFServer();
            }
            myserver.Start();
        }

        protected override void OnStop()
        {
            myserver.Close();
        }

        #endregion

        #region servcie public method

        public void StartService() { OnStart(null); }
        
        public void StopService() { OnStop(); }

        #endregion

        #region events

        /// <summary>
        /// thrown whenever the GPS Data stored in GNF service is changed
        /// send the new GPS Data
        /// </summary>
        public event OnGPSDataChangedEventHandler OnGPSDataChanged;

        /// <summary>
        /// thrown whenever the GPS Data stroed in GNF service is changed, send the
        /// new GPS Data and the time of the change
        /// </summary>
        public event TimedOnGPSDataChangedEventHandler TimedOnGPSDataChanged;

        #endregion
    }
}
